#include<math.h>
#include<iostream>
#include<windows.h>

using namespace std;

int x=0,y=0,z=0;



void qiuyu(int a,int b, int c)
{
	int m[5],n[5],o[5];
	for(int i=0;i<=4;i++){
		m[i]=a+i*3;
	}
	for(int i=0;i<=4;i++){
		n[i]=b+i*3;
	}
	for(int i=0;i<=4;i++){
		o[i]=c+i*6;
	}
	
	for(int i=0;i<=4;i++){
		for(int j=0;j<=4;j++){
			for(int k=0;k<=4;k++){
				if((m[i]==n[j]+o[k])||(n[j]==m[i]+o[k])||(o[k]==m[i]+n[j]))
				{
					z=m[i];
					y=n[j];
					x=o[k];
					return ;
				}
			}
		}
	}
}

int main()
{
	int a,b,c,m1,m2,m3,waiting;
	SetConsoleCP(65001);
	cout << "注意A盘为最内圈；" << endl;
	cout << "B盘为中间圈；" << endl;
	cout << "C盘为最外圈；" << endl;
	cout << "最少转次为目前要转几次才能让他到左边的位置" << endl;
	cout << "点位图：" << endl << endl;
	cout << "		6		5" << endl << endl << endl << endl << "1						4" << endl << endl << endl << endl <<  "		2		3" << endl;
	cout << endl << endl;
	
	cout << "请输入A盘最少转次：" << endl;
	cin >> a;
	cout << "请输入B盘最少转次：" << endl;
	cin >> b;
	cout << "请输入C盘最少转次：" << endl;
	cin >> c;
	cout << endl << endl;
	
//	cout << "A:" << a << endl << "B:" << b << endl << "C:" << c << endl;
	
	qiuyu(a,b,c);
	
	cout << "A需要转" << x << "次" << endl;
	cout << "B需要转" << y << "次" << endl;
	cout << "C需要转" << z << "次" << endl;
	cout << endl << endl;
	
	m1=max(x,y);	
	m2=max(x,z);
	m3=max(m1,m2);
	
	if(m3==x){
		cout << "需要转AC " << z << "次；转AB " << y << "次；" << endl << endl;
		cout << "请按Ctrl+C结束此程序" << endl;
	}
	if(m3==y){
		cout << "需要转AB " << x << "次；转BC " << z << "次；" << endl << endl;
		cout << "请按Ctrl+C结束此程序" << endl;
	}
	if(m3==z){
		cout << "需要转AC " << x << "次；转BC " << y << "次；" << endl << endl;
		cout << "请按Ctrl+C结束此程序" << endl;
	}
	
	cin >> waiting;
	return 0;
}

